<?php
	require_once($_SERVER['DOCUMENT_ROOT'].'uno-course-scheduler/include/config.inc.php');
	require_once($_SERVER['DOCUMENT_ROOT'].'uno-course-scheduler/include/top.inc.php');

//get variables passed from add.php
$classroom_id = mysql_real_escape_string(strip_tags($_POST['cid']));
$day_id = mysql_real_escape_string(strip_tags($_POST['day']));
$starttime = mysql_real_escape_string(strip_tags($_POST['start']));
$endtime = mysql_real_escape_string(strip_tags($_POST['end']));

$get_building_data = mysql_query("SELECT * FROM buildings b JOIN classrooms c ON c.building_id = b.id WHERE c.id = $classroom_id");
$building_id = mysql_result($get_building_data,0,'building_id');
$building_name = mysql_result($get_building_data,0,'building_name');
$abbreviation = mysql_result($get_building_data,0,'abbreviation');

$get_classroom_data = mysql_query("SELECT * FROM classrooms WHERE id = $classroom_id");
$room_num = mysql_result($get_classroom_data,0,'room_num');

echo "<h1>Add Classroom Closing in ".stripslashes($abbreviation)." ".stripslashes($room_num)."</h1>";

$query = "INSERT INTO classroom_closings (classroom_closing_id, classroom_id, day_id, start_time, end_time)
VALUES
('','$classroom_id','$day_id','$starttime','$endtime')";

$result = mysql_query($query);

if ($result)
{
	echo "Closing has been successfully added!";
	echo "<br />";
}
else
{
	echo "Closing was NOT able to be added at this time!";
	echo "<br />";
}

//close
mysql_close();

echo "<p>";
	echo "<a href='index.php?bid=$building_id&id=$classroom_id'>&lt;&lt; Back to Closings Portal</a><br />";
echo "</p>";

?>

<?php
	require_once($_SERVER['DOCUMENT_ROOT'].'uno-course-scheduler/include/bottom.inc.php');
?>